package logic

import (
	"context"
	"identity-authentication/moder/mysql"

	"identity-authentication/idenrpc/idenrpc"
	"identity-authentication/idenrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserShowLogic {
	return &UserShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserShowLogic) UserShow(in *idenrpc.UserShowRequest) (*idenrpc.UserShowResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	err := user.UserShow(mysql.DB, in.UserId)
	if err != nil {
		return nil, err
	}
	return &idenrpc.UserShowResponse{
		Username: user.Username,
		Password: user.Password,
		UserId:   int64(user.ID),
	}, nil
}
